package colthgame.app;

import android.content.Context;
import android.content.res.TypedArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {

	public ImageAdapter( Context c ) {
		mContext = c;
		TypedArray a = mContext.obtainStyledAttributes(R.styleable.Gallery);
        mGalleryItemBackground = a.getResourceId(
                R.styleable.Gallery_android_galleryItemBackground, 0);
        a.recycle();
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mImageIds.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mImageIds[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		 ImageView i = new ImageView(mContext);

		 float fD = mContext.getResources().getDisplayMetrics().density;
         i.setImageResource(mImageIds[position]);
         i.setScaleType(ImageView.ScaleType.FIT_XY);
         i.setLayoutParams( new Gallery.LayoutParams( (int)(100*fD), (int)(100*fD) ));
         i.setBackgroundResource(mGalleryItemBackground);
         
         return i;
	}
	
	  private Context mContext;
	  private int mGalleryItemBackground;
	  private Integer[] mImageIds = {
              R.drawable.pantsnskirt_menu,
              R.drawable.top_menu,
              R.drawable.necklace_menu,
              R.drawable.bangle_menu,
              R.drawable.gallery_photo_1,
              R.drawable.shoes_menu,
              R.drawable.hairpin_menu,
              R.drawable.earring_menu,
              R.drawable.bag_menu,
              R.drawable.gallery_photo_1,
              };

}
